package org.herrdommel.wakemeup.util;

import org.herrdommel.wakemeup.R;
import org.herrdommel.wakemeup.app.AlarmEditor;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;

public class DialogFactory {

	// dialog ids
	public static final int DIALOG_ABOUT = 0x01;
	public static final int DIALOG_LIST_EMPTY = 0x02;

	public static Dialog createDialog(final int id, final Context context) {
		switch (id) {
			case DIALOG_ABOUT :
				return new AlertDialog.Builder(context).setTitle(R.string.dlgAboutTitle)
						.setIcon(R.drawable.ic_launcher).setMessage(R.string.dlgAboutMessage)
						.setNegativeButton(R.string.dlgClose, new DialogInterface.OnClickListener() {
							@Override
							public void onClick(final DialogInterface dialog, final int which) {
								dialog.dismiss();
							}
						}).create();
			case DIALOG_LIST_EMPTY :
				return new AlertDialog.Builder(context).setTitle(R.string.dlgNoAlarmsAvailableTitle)
						.setIcon(R.drawable.ic_launcher).setMessage(R.string.dlgNoAlarmsAvailableMessage)
						.setNegativeButton(R.string.dlgNo, new OnClickListener() {
							@Override
							public void onClick(final DialogInterface dialog, final int which) {
								dialog.dismiss();
							}
						}).setPositiveButton(R.string.dlgYes, new OnClickListener() {
							@Override
							public void onClick(final DialogInterface dialog, final int which) {
								final Intent newAlarmIntent = new Intent(context, AlarmEditor.class);
								context.startActivity(newAlarmIntent);
							}
						}).create();
			default :
				return null;
		}
	}
}
